<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript" src="/static/js/jquery-1.11.2.min.js"></script>
	<script charset="utf-8" src="//map.qq.com/api/js?v=2.exp"></script>
</head>
<body>
	<div id="container" style="width:100%; height:400px"></div>
	<input type="text" id="address" value="陕西省西安市雁塔区高新四路志诚商务"><br/>
	<button id="addbtn">地址转换1</button>
	<button id="addbtn2">地址转换2</button>
</body>
</html>
<script type="text/javascript">
 function loadScript() { //&key=RWGBZ-JZVK3-NM73J-36ZXP-4W3MS-7FFD4
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://map.qq.com/api/js?v=2.exp&callback=init";
  document.body.appendChild(script);
}
window.onload = loadScript;
    var myLatlng = new qq.maps.LatLng(34.2373,108.89669);
    var myOptions = {
    zoom: 12,
    center: myLatlng,
    mapTypeId: qq.maps.MapTypeId.ROADMAP
  }
  var map = new qq.maps.Map(document.getElementById("container"), myOptions);
  function init() {
  	/*var geocoder = new qq.maps.Geocoder(callbacks);
  	var addrsss=$("#address").val();
    geocoder.getLocation(addrsss);*/
    var myLatlng = new qq.maps.LatLng(34.224140,108.882710);
    var myOptions = {
    zoom: 16,
    center: myLatlng,
    mapTypeId: qq.maps.MapTypeId.ROADMAP
  }
  var map = new qq.maps.Map(document.getElementById("container"), myOptions);
  var marker = new qq.maps.Marker({
    position: myLatlng,
    map: map,
    title:"测试地图标注标题"
   });
    var label = new qq.maps.Label({
    position: myLatlng,
    map: map,
    content:'文本内容'
   });
      //添加到提示窗
    var info = new qq.maps.InfoWindow({
        map: map
    });
    //获取标记的点击事件
    qq.maps.event.addListener(marker, 'click', function() {
        info.open(); 
        info.setContent('<div style="text-align:center;white-space:nowrap;'+
        'margin:10px;">单击标记</div>');
        info.setPosition(myLatlng); 
    });
    var listener = qq.maps.event.addListener(
    map,
    'click',
    function(event) {
    	console.log(event);
        alert('您点击的位置为:[' + event.latLng.getLng() +
        ',' + event.latLng.getLat() + ']');
    }
  );
}
var callbacks={
    complete:function(result){
    	console.log(result.detail.location);
    	alert(result.detail.location);
        map.setCenter(result.detail.location);
        var marker = new qq.maps.Marker({
            map:map,
            position: result.detail.location,
            title:"测试地图标注标题"
        });
    },
}
$("#addbtn").click(function()
{
	init();
});
$("#addbtn2").click(function()
{
	  geocoder = new qq.maps.Geocoder(callbacks);
  	var addrsss=$("#address").val();
    geocoder.getLocation(addrsss);
    var geocoder = new qq.maps.Geocoder({
    complete:function(result){
        alert('成功：'+result.detail.address);
       }
    });
    var coord=new qq.maps.LatLng(34.22414,108.88271);
    geocoder.getAddress(coord);
});
</script>